package com.lanzhou.yuanfen.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanzhou.yuanfen.exception.RollBackException;
import com.lanzhou.yuanfen.sys.entity.Permission;
import com.lanzhou.yuanfen.sys.entity.RolePermission;
import com.lanzhou.yuanfen.sys.mapper.PermissionMapper;
import com.lanzhou.yuanfen.sys.mapper.RolePermissionMapper;
import com.lanzhou.yuanfen.sys.service.IPermissionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author lcllge
 * @since 2019-12-02
 */
@Service
@Transactional(propagation = Propagation.NESTED, isolation = Isolation.DEFAULT, rollbackFor = RollBackException.class)
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements IPermissionService {


    @Resource
    private PermissionMapper permissionMapper;

    @Resource
    private RolePermissionMapper rolePermissionMapper;

    @Override
    public void removePerm(String permKey) {
        rolePermissionMapper.delete(new UpdateWrapper<RolePermission>().eq("perm_key", permKey));
        permissionMapper.deleteById(permKey);
    }

}
